This example checks to see if the specified key, SOFTWARE\\Microsoft\\TestApp\\1.0, exists and creates it if it does not.
Private Sub DoesKeyExist
Dim regVersion As Microsoft.Win32.RegistryKey
regVersion = _
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\TestApp\\1.0", True)
If regVersion Is Nothing Then
regVersion = _
Microsoft.Win32.Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\TestApp\\1.0")
End If
End Sub
This example requires:
Registry calls fail if either sufficient runtime permissions are not granted
(
Code:
Creating a Key In the Registry (Visual Basic) |